package com.polylink.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.polylink.base.Page;
import com.polylink.sys.bean.Function;
import com.polylink.sys.dao.IFunctionDao;
import com.polylink.sys.service.IFunctionService;

/**
 *@author xiliang.xiao
 *@date 2015年3月23日 上午9:03:48
 *
 **/
@Service
public class FunctionService implements IFunctionService{
	@Autowired
	private IFunctionDao functionDao;

	@Override
	public boolean save(Function function) {
		int i = 0;
		if(function.getId()!=null){
			i = functionDao.update(function);
		}else{
			i = functionDao.add(function);
		}
		if(i>0){
			return true;
		}
		return false;
	}

	@Override
	public Page list(Page p) {
		List<Function> list = functionDao.list(p);
		int count = functionDao.count(p);
		p.setRows(list);
		p.setTotal(count);
		return p;
	}

	@Override
	public boolean delete(String id) {
		int i = functionDao.delete(id);
		if(i>0){
			return true;
		}
		return false;
	}

}
